using UnityEngine;
using System.Collections;

/**
 * Script of data containing.
 * The purpose of this class is to contain and persist datas.
 * @author Benjamin Bruneau
 */
public class DataContainerScript : MonoBehaviour 
{
	private const int TIMEMAXLENGTH = 11; //Time string maxlength
	
	private const string SPACES = "      "; // Spaces needed for display
	
	public GameObject _goldText; // Gold Text in Pause
	public GameObject _silverText; // Silver Text in Pause
	public GameObject _bronzeText; // Bronze Text in Pause
	
	
	public string _nextLevel; //Next level
	public string _currentLevel; //Current level
	
	public float _altModifier = 0f; // Acceleration count for 
	public float _bronzeTime; // Bronze time
	public float _silverTime; // Silver time
	public float _goldTime; // Gold time
	
	public int _countActivatedStages = 0; // Activated stages count
	
	/**
	 * Called on initialization.
	 * @return void
	 */
	void Start () 
	{
		
		_goldText.GetComponent<TextMesh>().text = SPACES + convertTime(_goldTime);
		_silverText.GetComponent<TextMesh>().text = SPACES + convertTime(_silverTime);
		_bronzeText.GetComponent<TextMesh>().text = SPACES + convertTime(_bronzeTime);
		
	}
	
	/**
	 * Converts time for display.
	 * @param float
	 * @return string
	 */
	private string convertTime(float pTime)
	{
		//Format it
		string tempTimeString = System.TimeSpan.FromSeconds(pTime).ToString();
		string timeString;
		if (tempTimeString.Length < TIMEMAXLENGTH)
		{
			timeString = tempTimeString.Substring(3);
		} else {
			timeString = tempTimeString.Substring(3,8);
		}
		
		return timeString;
	}
	
}
